#include <bits/stdc++.h>
using namespace std;

int main() {
  int m;
  cin >> m;
  vector<int> ball;
  for (int i = 1; i <= m; i++) {
    int op;
    cin >> op;
    if (op == 2) {
      vector<int>::iterator p = min_element(ball.begin(), ball.end());
      cout << *p << endl;
      ball.erase(p);

    } else {
      int x;
      cin >> x;
      ball.push_back(x);
    }
  }

  return 0;
}
